<template>
  <ant-modal
    modalWidth="550"
    modalHeight="600"
    :visible="open"
    :modal-title="formTitle"
    :adjust-size="true"
    @cancel="cancel"
  >
    <a-form-model
      ref="form"
      :model="form"
      :rules="rules"
      slot="content"
      layout="vertical"
    >
      <a-row
        :gutter="32"
        style="width: 70%; margin-left: 15%"
        v-if="type == '廉政手册'"
      >
        <a-col :span="24">
          <a-form-model-item label="文件名称" prop="name">
            <a-input v-model="form.name" placeholder="请输入文件名称" />
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item label="文件类型" prop="fileType">
            <a-select
              placeholder="请选择文件类型"
              v-model="form.fileType"
              :getPopupContainer="
                (triggerNode) => {
                  return triggerNode.parentNode || document.body;
                }
              "
              style="width: 100%"
              allow-clear
            >
              <a-select-option
                v-for="(d, index) in fileTypeOptions"
                :key="index"
                :value="d.dictValue"
                >{{ d.dictLabel }}</a-select-option
              >
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item label="所属单位" prop="deptId">
            <a-tree-select
              v-model="form.deptId"
              placeholder="请选择所属单位"
              :tree-data="deptOptions"
              tree-default-expand-all
              :replaceFields="{
                children: 'children',
                title: 'title',
                key: 'id',
                value: 'id',
              }"
              @change="onTreeChange"
            >
            </a-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item label="文件上传：">
            <upload-file @ok="fileOk" />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row
        :gutter="32"
        style="width: 70%; margin-left: 15%"
        v-if="type == '专业书籍'"
      >
        <a-col :span="24">
          <a-form-model-item label="书籍类型" prop="fileType">
            <a-select
              placeholder="请选择籍类型"
              v-model="form.fileType"
              :getPopupContainer="
                (triggerNode) => {
                  return triggerNode.parentNode || document.body;
                }
              "
              style="width: 100%"
              allow-clear
            >
              <a-select-option
                v-for="(d, index) in fileTypeOptions"
                :key="index"
                :value="d.dictValue"
                >{{ d.dictLabel }}</a-select-option
              >
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item label="文件名称" prop="name">
            <a-input v-model="form.name" placeholder="请输入文件名称" />
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item label="所属单位" prop="deptId">
            <a-tree-select
              v-model="form.deptId"
              placeholder="请选择所属单位"
              :tree-data="deptOptions"
              tree-default-expand-all
              :replaceFields="{
                children: 'children',
                title: 'title',
                key: 'id',
                value: 'id',
              }"
              @change="onTreeChange"
            >
            </a-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item label="文件上传：" prop="">
            <upload-file @ok="fileOk" />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row
        :gutter="32"
        style="width: 70%; margin-left: 15%"
        v-if="type == '警示案例'"
      >
        <a-col :span="24">
          <a-form-model-item label="年份" prop="times">
            <a-date-picker
              v-model="form.times"
              mode="year"
              :format="yearFormat"
              :open="yearShowOne"
              @openChange="openChangeOne"
              @panelChange="panelChangeOne"
            ></a-date-picker>
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item label="类型" prop="fileType">
            <a-select
              placeholder="请选择类型(类型)"
              v-model="form.fileType"
              :getPopupContainer="
                (triggerNode) => {
                  return triggerNode.parentNode || document.body;
                }
              "
              style="width: 100%"
              allow-clear
            >
              <a-select-option
                v-for="(d, index) in fileTypeOptions"
                :key="index"
                :value="d.dictValue"
                >{{ d.dictLabel }}</a-select-option
              >
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item label="数量" prop="counts">
            <a-input-number
              v-model="form.counts"
              :min="0"
              style="width: 100%"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row :gutter="32" style="width: 70%; margin-left: 15%">
        <a-col :span="24">
          <a-form-model-item label="备注" prop="remark">
            <a-textarea
              v-model="form.remark"
              placeholder="请输入备注"
              :rows="4"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
    <template slot="footer">
      <a-button @click="cancel"> 取消 </a-button>
      <a-button type="primary" @click="submitForm"> 保存 </a-button>
    </template>
  </ant-modal>
</template>
<script>
import BizLianzhengJiansheAddForm from "./BizLianzhengJiansheForm";
export default {
  ...BizLianzhengJiansheAddForm,
};
</script>
